home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 1
/
SPACE - Library 1 - Volume 1.iso
/
program
/
16
/
checksum.fth
< prev
next >
Wrap
Text File
|
1985-11-19
|
768b
|
24 lines
\ Finds the checksum of a file. The checksum is computed by accumulating
\ bytes into a 16-bit (at least) word, and printing the least-significant
\ 16 bits of the result in both hex and decimal .
\
\ checsksum filename Print the checksum of the file
variable accum
: checksum \ filename ( -- )
accum off
reading
begin ifd @ fgetc dup 0>= while accum +! repeat
ifd @ close
base @
accum @ th ffff and
dup hex 6 u.r ." (hex) "
decimal 6 u.r ." (decimal)"
base !
cr
;
ecimal
: append-file ( -- )
begin
pad 4096 ifd @ fgets ( #bytes-read)
d